package com.feihong.yw189.dialog;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;

import com.feihong.yw189.R;
import com.feihong.yw189.activity.kaika.KaiKaActivity;

import static android.app.Activity.RESULT_OK;

/**
 * Created by 刘送心 on 2018/3/5.
 */

public class DetermineDialog   extends Dialog{

    private Activity activity;
    String acc_Type;
    String segmId;
    String standName;

    public DetermineDialog( Context context,String Acc_type,String Segm_id,String Stand_name) {
        super(context);
        this.activity = (Activity) context;
        this.acc_Type=Acc_type;
        this.segmId=Segm_id;
        this.standName=Stand_name;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.determine_dialog);

        TextView bt_ok = (TextView) findViewById(R.id.bt_ok);
        TextView bt_no = (TextView) findViewById(R.id.bt_no);
        bt_no.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
        bt_ok.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
                Intent mIntent=new Intent();
                Bundle  bundle=new Bundle();
                bundle.putString("Acc_type", acc_Type);
                bundle.putString("Segm_id", segmId);
                bundle.putString("Stand_name",standName);
                mIntent.putExtras(bundle);
                mIntent.setClass(activity,KaiKaActivity.class);
                activity.setResult(RESULT_OK, mIntent);
                activity.finish();
            }
        });
        Window window = getWindow();
        WindowManager.LayoutParams params = window.getAttributes();
        params.gravity = Gravity.CENTER;
        window.setAttributes(params);
    }

}
